import numpy as np

a = np.array([1, 2, 3, 4])
b = np.array((5, 6, 7, 8))
c = np.array([[1, 2, 3, 4],[4, 5, 6, 7], [7, 8, 9, 10]])

print("a.dtype", a.dtype, a)
print("b.dtype", b.dtype, b)
print("c.dtype",c.dtype, c)

# size
print("a.shape =", a.shape)
print("c.shape =", c.shape)

# change shape
c.shape=4,3
print(c)

# range, linespace, logspace
np.arange(0,1,0.1)
np.linspace(0, 1, 12)
np.logspace(0, 2, 20)

# fromstring
s = "abcdefgh"
d = np.fromstring(s, dtype=np.int8)
print("fromstring", d)

# from function
def func(i):
    return i%4+1
e = np.fromfunction(func, (10,))

def func2(i, j):
    return (i + 1) * (j + 1)
f = np.fromfunction(func2, (9,9))

# enumerate
for i, t in enumerate(c):
    print(type(i),i, type(t), t)

# reduce
g = np.add.reduce([1, 2,3])
print(g)
np.add.accumulate([[1,2,3],[4,5,6]], axis=1)